/**
 * The file enables `@/routes/index.js` to import all Router modules
 * in a one-shot manner. There should not be any reason to edit this file.
 */

const compose = require('koa-compose')
const glob = require('glob')
const { resolve } = require('path')
const Router = require('koa-router')()

// const router = new Router()


registerRouter = () => {
  let routers = []
  glob.sync(resolve(__dirname, './adminApi', '**/*.js'))
    .filter(value => (value.indexOf('index.js') === -1))
    .map(router => {
      routers.push(require(router).routes())
      routers.push(require(router).allowedMethods())
    })
  return compose(routers)
}

module.exports = registerRouter